<?php
$link = mysql_connect('localhost', 'shinetheweb', 'urmysunshine') or die('Could not connect: ' . mysql_error());
mysql_select_db('sunshinedeals') or die('Could not select database');

if(!isset($_REQUEST['keyword']))
	die('search string not set');

$keyword = trim($_REQUEST['keyword']);

if(strlen($keyword) < 2 )
	die('search string invalid');

$searchquery = "SELECT * FROM COUPONS WHERE COUP_NAME LIKE '%$keyword%' OR COUP_CATNAME LIKE '%$keyword%'
							OR COUP_VENDOR LIKE '%$keyword%' OR COUP_DESC LIKE '%$keyword%' ";

$result = mysql_query($searchquery);
$size = 0;
?>
<table border='1 solid black'>
	<?php
	while ($tuple = mysql_fetch_array($result, MYSQL_ASSOC)) {
		$size++;
	?>
	<tr>
		<?php foreach ($tuple as $value) { ?>
				<td><?=$value?></td>
		<?php } ?>
	</tr>
<?php } ?>

</table>

<?php
	mysql_free_result($result);
	mysql_close($link);
if($size == 0)
	echo 'No Results Found';
?>
